package com.briup.pts.web.controller;

import com.briup.pts.service.UploadService;
import com.briup.pts.config.response.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author 25095
 * @description
 * @data 2024/11/22-14:36
 */
@Tag(name="上传文件")
@RequiredArgsConstructor
@RestController
@RequestMapping("/file/upload")
public class UploadController {

    private final UploadService uploadService;
    @Operation(summary = "文件上传")
    @PostMapping
    public Result<?> upload(@RequestPart MultipartFile file){
        String url = uploadService.uploadToOss(file);
        return  Result.success(url).apply("上传成功");
    }
}
